-
Notifications
You must be signed in to change notification settings - Fork 66
feat(rf): FXC-1604 API for extending structures into pml #3026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 2 comments
89861b7 to
83e10f4
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
|
Are we sure this is not required for rc3? It's a schema change that will be blocked till 2.11. @George-Guryev-flxcmp @dbochkov-flexcompute @weiliangjin2021 |
If so, let's try to get it in for rc3. When is the deadline for merging PRs for rc3? |
83e10f4 to
4969e99
Compare
Can you get this in for tomorrow? |
Sure thing. |
98c56f5 to
a0cba1d
Compare
c9522d4 to
222c6fb
Compare
222c6fb to
c70e7f2
Compare
dbochkov-flexcompute
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to override _structures_not_at_edges
tidy3d/tidy3d/components/base_sim/simulation.py
Lines 160 to 188 in 7db47cf
| @pd.validator("structures", always=True) | |
| @skip_if_fields_missing(["size", "center"]) | |
| def _structures_not_at_edges(cls, val, values): | |
| """Warn if any structures lie at the simulation boundaries.""" | |
| if val is None: | |
| return val | |
| sim_box = Box(size=values.get("size"), center=values.get("center")) | |
| sim_bound_min, sim_bound_max = sim_box.bounds | |
| sim_bounds = list(sim_bound_min) + list(sim_bound_max) | |
| with log as consolidated_logger: | |
| for istruct, structure in enumerate(val): | |
| struct_bound_min, struct_bound_max = structure.geometry.bounds | |
| struct_bounds = list(struct_bound_min) + list(struct_bound_max) | |
| for sim_val, struct_val in zip(sim_bounds, struct_bounds): | |
| if anp.isclose(sim_val, struct_val): | |
| consolidated_logger.warning( | |
| f"Structure at 'structures[{istruct}]' has bounds that extend exactly " | |
| "to simulation edges. This can cause unexpected behavior. " | |
| "If intending to extend the structure to infinity along one dimension, " | |
| "use td.inf as a size variable instead to make this explicit.", | |
| custom_loc=["structures", istruct], | |
| ) | |
| continue | |
| return val |
Simulation
| if boundary[0].extrude_structures: | ||
| warn_extruded(structure, istruct, axis + "-min") | ||
| else: | ||
| warn(structure, istruct, axis + "-min") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if a structure is less than half wavelength away from pml, but still not close enough to be extruded?
| False, | ||
| title="Enable structure extrusion to PML", | ||
| description="Automatically extrude structures into the absorbing region (e.g., PML or adiabatic absorber)." | ||
| "Any structure located within `CLIP_OFFSET` of a simulation boundary will be extended through the full thickness of the PML/absorber." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to change within CLIP_OFFSET of to within {CLIP_OFFSET} cells of
| custom_loc=["structures", istruct], | ||
| ) | ||
|
|
||
| def warn_extruded(structure, istruct, side) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider extending the original warn with additional parameter, instead of a new mostly duplicating function
This PR adds feature for automatic extrusion of structures located next to the simulation boundaries into PML/Absorber. This is facilitated by additional field
enable_extrusionin classAbsorberSpec.Greptile Overview
Greptile Summary
This PR adds an API field
enable_extrusionto theAbsorberSpecclass, allowing users to enable automatic extrusion of structures into PML/Absorber boundary regions. The field is properly documented and tested.Key Changes:
enable_extrusionboolean field toAbsorberSpecclass (inherited byPML,StablePML, andAbsorber)Falseto maintain backward compatibilityImportant Notes:
extrude_structuresfield inWavePort, this likely prepares the groundwork for future implementationConfidence Score: 4/5
Important Files Changed
File Analysis
enable_extrusionboolean field toAbsorberSpecclass with proper default value and documentationenable_extrusionfield checking default values and exclusivity to absorber types; uses direct equality instead ofisfor boolean checksenable_extrusionfield inAbsorberSpecSequence Diagram
sequenceDiagram participant User participant Simulation participant BoundarySpec participant AbsorberSpec participant PML/Absorber User->>Simulation: Create simulation with boundary conditions User->>PML/Absorber: PML(enable_extrusion=True) PML/Absorber->>AbsorberSpec: Initialize with enable_extrusion field AbsorberSpec->>AbsorberSpec: Store enable_extrusion=True AbsorberSpec-->>PML/Absorber: Return configured boundary PML/Absorber-->>Simulation: Add to boundary specification Simulation->>BoundarySpec: Configure x/y/z boundaries Note over Simulation,BoundarySpec: Field is stored but not yet used in implementation Note over User,PML/Absorber: API surface prepared for future extrusion logic